package com.caimiao.miao.page.master.storage.manual;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.caimiao.miao.R;
import com.caimiao.miao.interfaces.BaseFragmentImpl;

public class ManualFragment extends BaseFragmentImpl<IManualContact.Presenter> implements IManualContact.View, View.OnClickListener {
    public static final String TAG = ManualFragment.class.getSimpleName();
    private ImageView mIvHead;
    private TextView mTvName;
    private EditText mEtCount;

    @Override
    public int getLayoutRes() {
        return R.layout.fragment_storage_manual;
    }

    @Override
    public void initUI() {
        setTitle("手动出票");
        mIvHead = mRootView.findViewById(R.id.storageManualIvHead);
        mTvName = mRootView.findViewById(R.id.storageManualTvName);
        mEtCount = mRootView.findViewById(R.id.storageManualEtCount);
    }

    @Override
    public void initLogic() {
        mRootView.findViewById(R.id.storageManualBtnOk).setOnClickListener(this::onClick);
        new ManualPresenter(this);
    }

    @Override
    public void close(Bundle extra) {

    }

    @Override
    public String getCount() {
        return mEtCount.getText().toString();
    }

    @Override
    public void setHead(String pic) {
        Glide.with(this).load(pic).apply(RequestOptions.circleCropTransform()).into(mIvHead);
    }

    @Override
    public void setName(String name) {
        mTvName.setText(name);
    }

    @Override
    public void onClick(View v) {
        mPresenter.confirm(getContext(), getCount());
    }
}
